package cnisetup

import (
	"context"
)

type BIGIPCNI interface {
	Deploy() error
	Cleanup() error
}
type K8SCNI interface {
	Setup() error
	Teardown() error

	nodeConfigs() (map[string]interface{}, error)
}

type FlannelVxlanContext struct {
	CNIContext
	Kube KubeSetting
}

type FlannelHostgwContext struct {
	CNIContext
	Kube KubeSetting
}

type CalicoBGPContext struct {
	CNIContext
	Kube KubeSetting
}

type CiliumContext struct {
	CNIContext
	Kube KubeSetting
}

type UnknownContext struct {
	CNIContext
	Kube KubeSetting
}

type BIGIPOnlyContext struct {
	CNIContext
	Kube KubeSetting
}

type CNIContext struct {
	context.Context
	CNIConfig
}

type CNIConfigs []CNIConfig

type SelfIP struct {
	Name             string
	IpMask           string `yaml:"ipMask"`
	VlanOrTunnelName string `yaml:"vlanOrTunnelName"`
}

type Management struct {
	Username  string
	IpAddress string `yaml:"ipAddress"`
	Port      *int
	Password  string
}

type Tunnel struct {
	Name         string
	Port         int
	LocalAddress string `yaml:"localAddress"`
	Key          string
	FloodingType string `yaml:"floodingType"`
	tunnelMac    string
	FdbFrom      []string `yaml:"fdbFrom"`
}

type NodeConfig struct {
	PublicIP string `yaml:"publicIP"`
	PodCIDR  string `yaml:"podCIDR"`
}

type Route struct {
	Network     string
	TmInterface string `yaml:"tmInterface"`
}

type Vlan struct {
	Name       string
	Tag        int
	Interfaces []Interface
}

type Interface struct {
	Name   string
	Tagged bool
}

type BGP struct {
	Name         string
	LocalAS      string   `yaml:"localAS"`
	RemoteAS     string   `yaml:"remoteAS"`
	NeighborFrom []string `yaml:"neighborFrom"`
}

type VTEP struct {
	Endpoint string
	CIDR     string `yaml:"cidr"`
	Mask     string
	mac      string
}

type KubeSetting struct {
	Config  string       `yaml:"config"`
	CNIType string       `yaml:"cniType"`
	PeerIPs []string     `yaml:"peerIPs"` // for calico bgp peer creation
	Nodes   []NodeConfig `yaml:"nodes"`   // for flannel vxlan virtual node
	Vteps   []VTEP       `yaml:"vteps"`
}

type CNIConfig struct {
	Mgmt    Management `yaml:"management"`
	Vlans   []Vlan
	Tunnels []Tunnel
	SelfIPs []SelfIP `yaml:"selfIPs"`
	BGPs    []BGP    `yaml:"bgps"`
	Routes  []Route
	Kubes   map[string]KubeSetting
}
